class Solution(object):
    def smallestRangeI(self, nums, k):
        """
        :type nums: List[int]
        :type k: int
        :rtype: int
        """
        a = max(nums)
        b = min(nums)
        if a - b >= 2 * k:
            return a - b - 2 * k
        else:
            return 0
